package com.teamcenter.rac.massupdate.databinding;

import org.eclipse.core.databinding.Binding;
import org.eclipse.jface.wizard.WizardPage;

import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.massupdate.ui.ChangeItemRevisionSearchDialog;
import com.teamcenter.rac.massupdate.ui.ItemRevisionSearchDialog;
public abstract class AbstractFindObservable
  extends AbstractModelObservable
{
  private WizardPage m_wizardPage;
  private Binding m_bindingToUpdate;
  private String m_massUpdateType;
  
  public AbstractFindObservable()
  {
    super(Boolean.FALSE, Boolean.class);
  }
  
  public String getSearchText()
  {
    return null;
  }
  
  public WizardPage getWizardPage()
  {
    return this.m_wizardPage;
  }
  
  public void setSearchText(String paramString) {}
  
  public void setWizardPage(WizardPage paramWizardPage)
  {
    this.m_wizardPage = paramWizardPage;
  }
  
  public void setMassUpdateType(String paramString)
  {
    this.m_massUpdateType = paramString;
  }
  
  protected TCComponentItemRevision findChangeItemRevision()
  {
    if (this.m_wizardPage != null)
    {
      ChangeItemRevisionSearchDialog localChangeItemRevisionSearchDialog = new ChangeItemRevisionSearchDialog(this.m_wizardPage.getShell());
      localChangeItemRevisionSearchDialog.setMassUpdateType(this.m_massUpdateType);
      String str = getSearchText();
      if ((str != null) && (!str.isEmpty()))
      {
        localChangeItemRevisionSearchDialog.getSearchCriteria().setItemId(str);
        localChangeItemRevisionSearchDialog.performSearch();
      }
      if (localChangeItemRevisionSearchDialog.open() == 0)
      {
        setSearchText(localChangeItemRevisionSearchDialog.getSearchCriteria().getItemId());
        if (this.m_bindingToUpdate != null) {
          this.m_bindingToUpdate.updateModelToTarget();
        }
        return localChangeItemRevisionSearchDialog.getResult();
      }
    }
    return null;
  }
  
  protected TCComponentItemRevision findItemRevision()
  {
    if (this.m_wizardPage != null)
    {
      ItemRevisionSearchDialog localItemRevisionSearchDialog = new ItemRevisionSearchDialog(this.m_wizardPage.getShell());
      String str = getSearchText();
      if ((str != null) && (!str.isEmpty()))
      {
        localItemRevisionSearchDialog.getSearchCriteria().setItemId(str);
        localItemRevisionSearchDialog.performSearch();
      }
      if (localItemRevisionSearchDialog.open() == 0)
      {
        setSearchText(localItemRevisionSearchDialog.getSearchCriteria().getItemId());
        if (this.m_bindingToUpdate != null) {
          this.m_bindingToUpdate.updateModelToTarget();
        }
        return localItemRevisionSearchDialog.getResult();
      }
    }
    return null;
  }
  
  public void setBinding(Binding paramBinding)
  {
    this.m_bindingToUpdate = paramBinding;
  }
  
  protected Binding getBinding()
  {
    return this.m_bindingToUpdate;
  }
}
